
//是否授权
export const Unauthorized = function (unauthorized) {
    if (unauthorized == '1') {
        return '未授权'
    } else if (unauthorized == '2') {
        return '已授权'
    }
}
//string 2021-12-21 11:23:07 --->11:23
export const Time = function (date) {
    if (date) {
        let arr = date.split(' ')[1].split(':')
        return arr[0] + ':' + arr[1]
    } else {
        return date
    }
}
// 数字千分格式化
export const formatNum = (num) => {
    if (!num) return '0'
    let flag = num >= 0 ? true : false;
    const numArr = Math.abs(num).toString().split('.');
    let right = numArr[1] === undefined ? '' : '.' + numArr[1];
    let leftArr = numArr[0].split('');
    let res = [];
    for (let i = leftArr.length - 1, count = 0; i >= 0; i--, count++) {
        if (count % 3 === 0 && i != leftArr.length - 1) res.unshift(',');
        res.unshift(leftArr[i]);
    }
    return flag ? res.join('') + right : '-' + res.join('') + right;
}